package com.service;

import com.dao.ManManufacturerMapper;
import com.dao.UserMapper;
import com.pojo.ManManufacturer;
import com.pojo.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ManManufacturerService {

    @Resource
    private ManManufacturerMapper manufacturerMapper;
    @Resource
    private UserMapper userMapper;

    public List<ManManufacturer> findAll() {
        return manufacturerMapper.findAll();
    }

    public ManManufacturer findById(Integer id) {
        return manufacturerMapper.findById(id);
    }

    public void insert(ManManufacturer manufacturer, User user) {
        manufacturerMapper.insert(manufacturer);
        user.setManId(manufacturerMapper.selectLastId());
        userMapper.update(user);
    }

    public void update(ManManufacturer manufacturer) {
        manufacturerMapper.update(manufacturer);
    }

    public void deleteById(Integer id) {
        manufacturerMapper.deleteById(id);
    }
}
